import 'package:equatable/equatable.dart';

part 'errors.dart';

abstract class ValidateEmail {
  EmailValidationError? call({
    required String email,
  });
}

class ValidateEmailImpl implements ValidateEmail {
  const ValidateEmailImpl();

  @override
  EmailValidationError? call({
    required String email,
  }) {
    final regExp = RegExp(r'.+@.+\..+');

    if (regExp.hasMatch(email)) {
      return null;
    }

    return const EmailValidationError();
  }
}
